<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <script src="../../react18/react.development.js"></script>
    <script src="../../react18/react-dom.development.js"></script>
    <script src="../../react18/babel.min.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script type="text/babel">
      /* 
       props de 批量传递：
        通过传输一个对象的方式 来传递多个数据
          方法一 直接将这个对象整体传递出去 "<Son item={item} />"将对象item传递到props
          解构方法：const { name, age, sex } = this.props.item;
          方法二 将对象展开传递 "<Son {...item}>"更简单更简洁
          解构方法：const { name, age, sex } = this.props;
      */
      class Son extends React.Component {
        render() {
          const { name, age, sex } = this.props;
          // const { name, age, sex } = this.props.item;
          return (
            <div>
              <h2>我的名字是{name}</h2>
              <h2>我的年龄是{age}</h2>
              <h2>我的性别是{sex}</h2>
            </div>
          );
        }
      }
      class App extends React.Component {
        state = {
          students: [
            { id: 1, name: "张三", age: 18, sex: "男" },
            { id: 2, name: "李四", age: 20, sex: "女" },
            { id: 3, name: "王五", age: 12, sex: "女" },
          ],
        };

        render() {
          const { students } = this.state;
          return (
            <ul>
              {students.map((item) => {
                return (
                  <li key={item.id}>
                    <h2>下边是{item.name}的自我介绍</h2>
                    <Son {...item} />
                  </li>
                );
              })}
            </ul>
          );
        }
      }
      ReactDOM.createRoot(document.getElementById("app")).render(<App />);
    </script>
  </body>
</html>
